package com.tpv.tv.lib.pdf;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

import androidx.core.content.ContextCompat;

public class PdfProgressDrawable extends Drawable {
    private final Paint paint;
    private final int radius;

    public PdfProgressDrawable(Context context) {
        this.paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        this.paint.setColor(ContextCompat.getColor(context, R.color.page_indicator));
        this.paint.setStyle(Paint.Style.STROKE);
        this.radius = 15;
    }

    @Override
    public void draw(Canvas canvas) {
        Rect bounds = getBounds();
        canvas.drawRoundRect(0, 0,(bounds.right - bounds.left) / 2f, (bounds.bottom - bounds.top) / 2f, radius, radius, paint);
    }

    // Delegate all other methods to the paint
    @Override
    public void setAlpha(int alpha) {
        paint.setAlpha(alpha);
    }

    @Override
    public void setColorFilter(ColorFilter cf) {
        paint.setColorFilter(cf);
    }

    @Override
    public int getOpacity() {
        return PixelFormat.TRANSLUCENT;
    }

    @Override
    public int getIntrinsicWidth() {
        return radius;
    }

    @Override
    public int getIntrinsicHeight() {
        return radius;
    }
}
